package com.chinamsp.codegen.convert.db;

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

import com.chinamsp.codegen.CodeGenConstants;
import com.chinamsp.dydb.configuration.DynamicDataSourceAutoConfiguration;

/**
 * db  condition
 * @author shifenghu
 *
 */
@ConditionalOnBean(DynamicDataSourceAutoConfiguration.class)
@EnableConfigurationProperties(DbCodeGenProperties.class)
public class DbCodeGenConfigruation{
	
	@Bean
	@ConditionalOnProperty(prefix = CodeGenConstants.PROPERTIES_PREFIX, name = "schema")
	public DbCodeGenProcessor dbCodeGenProcessor(ConfigurableApplicationContext context) {
		return context.getAutowireCapableBeanFactory().createBean(DbCodeGenProcessor.class);
	}
}
